package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.DataAndValueWeek;
import com.zzyl.nursing.domain.FamilyMember;
import com.zzyl.nursing.dto.DeviceDto;
import com.zzyl.nursing.dto.FamilyMemberDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;
import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    /**
     * 绑定老人
     *
     */
 @PostMapping("/add")
    public AjaxResult add(@RequestBody FamilyMemberDto familyMemberDto)
    {
             familyMemberService.addFamilyElder(familyMemberDto);
        return success();
    }

    /**
     * 查询家人列表
     *
     */
    @GetMapping("/my")
    public AjaxResult selectMy(Integer pageNum,Integer pageSize)
    {
        return success(familyMemberService.selectMy(pageNum,pageSize));
    }
    /**
     * 分页查询
     *
     */
    @GetMapping("/list-by-page")
    @ApiOperation("分页查询")
    public R<List<FamilyElderListVo>> getByPage(Integer pageNum, Integer pageSize)
    {
   return R.ok(familyMemberService.getByPage(pageNum, pageSize));
    }

    /**
     *
     * 查询健康数据
     */
    @PostMapping("/QueryDevicePropertyStatus")
    public AjaxResult QueryDevicePropertyStatus(@RequestBody DeviceDto deviceDto)
    {
        List<PropertyStatusInfo> list = familyMemberService.QueryDevicePropertyStatus(deviceDto);

        PropertyStatusInfoVo propertyStatusInfoVo = new PropertyStatusInfoVo();

        propertyStatusInfoVo.setPropertyStatusInfo(list);

        PropertyStatusVo propertyStatusVo = new PropertyStatusVo();
        propertyStatusVo.setList(propertyStatusInfoVo);

       return AjaxResult.success(propertyStatusVo);

    }

    /**
     * 按天统计查询指标数据
     *
     *
     */
    @GetMapping("/queryDeviceDataListByDay")


public AjaxResult queryDeviceDataListByDay(String iotId,String functionId,Long startTime,Long endTime)
    {
        DeviceDataDayVo deviceDataDayVo = familyMemberService.queryDeviceDataListByDay(iotId, functionId, startTime, endTime);
        return AjaxResult.success(deviceDataDayVo.getList());
    }

/**
 * 按周统计查询指标数据
 *
 */
  @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(String iotId,String functionId,Long startTime,Long endTime)
    {
      DataAndValueWeekVo deviceDataDayVo = familyMemberService.queryDeviceDataListByWeek(iotId, functionId, startTime, endTime);
        return AjaxResult.success(deviceDataDayVo.getList());
    }

    @GetMapping("/pageQueryAlertData")
    public AjaxResult pageQueryAlertData(String iotId,String functionId,Long startTime,Long endTime)
    {
        return success();
    }

}
